<?php 
	$lists  = getContentList($item['id']); 
?>
<input type="hidden" name="action" value="editor" />
<input type="hidden" name="item" value="<?php echo $item['id']; ?>" />
<div class="menu_top">
	<input type="submit" name="add_new_list" value="Add new list" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" />&nbsp;&nbsp;
	<br /><br />
</div>
<div align="center" class="content_template">
<?php 
	if($lists):
		foreach($lists as $list): 
			if($list['access'] < 1)
			{ $bg = 'access_0.gif'; }
			else
			{ $bg = 'access_1.gif'; }
?>
	<div align="center" style="padding:4px; border:1px solid grey; float:left;">
		<div class="menu_top" style="padding-bottom:4px; border-bottom:1px solid black;">
			<input type="hidden" name="list_id[]" value="<?php echo $list['id']; ?>" />
			
			<select name="direction[]" onchange="submit();" style="width:130px; margin-bottom:4px;">
				<option value="0" <?php if($list['direction'] == 0){ echo 'selected'; } ?>>Horisontal</option>
				<option value="1" <?php if($list['direction'] == 1){ echo 'selected'; } ?>>Vertical</option>
			</select>
			<img class="activate" src="../images/system/arrow_up_20.gif" onmousedown="document.getElementById('list_up').value='<?php echo $list['id']; ?>';" onmouseup="edit_form.submit();" />
			<img class="activate" src="../images/system/arrow_down_20.gif" value="0" onmousedown="document.getElementById('list_down').value='<?php echo $list['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php if($list['active'] == 0): ?>
				<img class="activate" src="../images/system/active_<?php echo $list['active']; ?>_25.gif" alt="activate" onmousedown="document.getElementById('list_activate').value='<?php echo $list['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php else: ?>
				<img class="activate" src="../images/system/active_<?php echo $list['active']; ?>_25.gif" alt="deactivate" onmousedown="document.getElementById('list_deactivate').value='<?php echo $list['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php endif; ?>
			<img class="activate" src="../images/system/trash_25.gif" alt="deactivate" onmousedown="document.getElementById('list_delete').value='<?php echo $list['id']; ?>';" onmouseup="edit_form.submit();" />
			<br />
			<select name="access[]" onchange="submit();" style="width:130px; background:transparent url(../images/system/<?php echo $bg; ?>) no-repeat scroll left top; padding-left:18px;" >
				<?php
				foreach($groups as $group)
				{
					if($list['access'] == $group['id'])
					{ echo '<option value="'.$group['id'].'" selected>'.$group['name'].'</option>'; }
					else
					{ echo '<option value="'.$group['id'].'">'.$group['name'].'</option>'; }
				}
				?>
			</select>
			<button class="buttons" name="new_list_item" value="<?php echo $list['id']; ?>" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;">New item</button>
			
		</div>
		<?php if($list['items']): ?>
		<div style="clear:left; float:left; ">
			<ul style="list-style-type:none; margin:0pt; padding:0pt;">
			
				<?php 
				foreach($list['items'] as $subitem): ?>
				<li style="<?php if($list['direction'] == 0): echo 'display:inline;'; endif;?> margin:0pt; padding:0pt;">
					<div style="<?php if($list['direction'] == 0): echo 'float:left;'; endif;?> margin:4px; padding:4px; border:1px dotted silver;">
					<input type="hidden" name="list_item_id[]" value="<?php echo $subitem['id']; ?>" />
					<input type="hidden" name="list_item_parent_id[]" value="<?php echo $list['id']; ?>" />
					<select name="content_type[]" onchange="submit();" style="width:130px;">
						<option value="0" <?php if($subitem['content_type'] == 0){ echo 'selected'; } ?>>Empty</option>
						<option value="1" <?php if($subitem['content_type'] == 1){ echo 'selected'; } ?>>Module</option>
						<option value="2" <?php if($subitem['content_type'] == 2){ echo 'selected'; } ?>>HTML Page</option>
						<option value="3" <?php if($subitem['content_type'] == 3){ echo 'selected'; } ?>>Video Clip</option>
						<option value="4" <?php if($subitem['content_type'] == 4){ echo 'selected'; } ?>>Photo Gallery</option>
					</select><br clear="left" />
					<select name="content_id[]" onchange="submit();" style="width:130px;">
						<option value="0">Empty</option>
						<?php
						if($subitem['content_type'] == 1)
						{
							foreach($modules as $module)
							{
								if($module['id'] == $subitem['content_id'])
								{ echo '<option value="'.$module['id'].'" selected="selected">'.$module['name_l'].' '.$module['name_r'].'</option>'; }
								else
								{ echo '<option value="'.$module['id'].'" >'.$module['name_l'].' '.$module['name_r'].'</option>'; }
							}
						}
						if($subitem['content_type'] == 2)
						{
							foreach($htmls as $html)
							{
								if($html['id'] == $subitem['content_id'])
								{ echo '<option value="'.$html['id'].'" selected="selected">'.$html['name_l'].' '.$html['name_r'].'</option>'; }
								else
								{ echo '<option value="'.$html['id'].'" >'.$html['name_l'].' '.$html['name_r'].'</option>'; }
							}
						}
						if($subitem['content_type'] == 3)
						{
							foreach($videos as $video)
							{
								if($video['id'] == $subitem['content_id'])
								{ echo '<option value="'.$video['id'].'" selected="selected">'.$video['name'].'</option>'; }
								else
								{ echo '<option value="'.$video['id'].'" >'.$video['name'].'</option>'; }
							}
						}
						if($subitem['content_type'] == 4)
						{
							foreach($galleries as $gallery)
							{
								if($gallery['id'] == $subitem['content_id'])
								{ echo '<option value="'.$gallery['id'].'" selected="selected">'.$gallery['name'].'</option>'; }
								else
								{ echo '<option value="'.$gallery['id'].'" >'.$gallery['name'].'</option>'; }
							}
						}
						?>
					</select><br clear="left" />
					<?php 
						if($subitem['access'] < 1)
						{ $bg = 'access_0.gif'; }
						else
						{ $bg = 'access_1.gif'; }
					?>
					<select name="list_item_access[]" onchange="submit();" style="width:130px; background:transparent url(../images/system/<?php echo $bg; ?>) no-repeat scroll left top; padding-left:18px;" >
						<?php
						foreach($groups as $group)
						{
							if($group['id'] >= $list['access'])
							{
								if($subitem['access'] == $group['id'])
								{ echo '<option value="'.$group['id'].'" selected>'.$group['name'].'</option>'; }
								else
								{ echo '<option value="'.$group['id'].'">'.$group['name'].'</option>'; }
							}
						}
						?>
					</select><br />
					<?php if($list['direction'] == 0): ?>
					<img class="activate" src="../images/system/arrow_left_20.gif" onmousedown="document.getElementById('list_item_up').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<img class="activate" src="../images/system/arrow_right_20.gif" value="0" onmousedown="document.getElementById('list_item_down').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<?php else: ?>
					<img class="activate" src="../images/system/arrow_up_20.gif" onmousedown="document.getElementById('list_item_up').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<img class="activate" src="../images/system/arrow_down_20.gif" value="0" onmousedown="document.getElementById('list_item_down').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<?php endif; ?>
					<?php if($subitem['active'] == 0): ?>
						<img class="activate" src="../images/system/active_<?php echo $subitem['active']; ?>_25.gif" alt="activate" onmousedown="document.getElementById('list_item_activate').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<?php else: ?>
						<img class="activate" src="../images/system/active_<?php echo $subitem['active']; ?>_25.gif" alt="deactivate" onmousedown="document.getElementById('list_item_deactivate').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					<?php endif; ?>
					<img class="activate" src="../images/system/trash_25.gif" alt="deactivate" onmousedown="document.getElementById('list_item_delete').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
					</div>
				</li>
				<?php endforeach; ?>
			</ul>
		</div>
		<?php endif; ?>
	</div>
<?php endforeach; ?>
<input type="hidden" id="list_up" name="list_up" value="0" />
<input type="hidden" id="list_down" name="list_down" value="0" />
<input type="hidden" id="list_delete" name="list_delete" value="0" />
<input type="hidden" id="list_activate" name="list_activate" value="0" />
<input type="hidden" id="list_deactivate" name="list_deactivate" value="0" />
<input type="hidden" id="list_item_up" name="list_item_up" value="0" />
<input type="hidden" id="list_item_down" name="list_item_down" value="0" />
<input type="hidden" id="list_item_delete" name="list_item_delete" value="0" />
<input type="hidden" id="list_item_activate" name="list_item_activate" value="0" />
<input type="hidden" id="list_item_deactivate" name="list_item_deactivate" value="0" />
<?php endif; ?>	
</div>
